//
// Created by xili on 2024/8/22 9:04.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    int garbageCollection(vector <string> &garbage, vector<int> &travel) {
        int ans = garbage[0].size();
        int a = 0, b = 0, c = 0;
        int n = garbage.size();
        int travelsum = 0;
        for (int i = 1; i < n; i++) {
            ans += garbage[i].size();
            travelsum += travel[i - 1];
            if (garbage[i].find('M') != string::npos) {
                a = travelsum;
            }
            if (garbage[i].find('P') != string::npos) {
                b = travelsum;
            }
            if (garbage[i].find('G') != string::npos) {
                c = travelsum;
            }
        }
        return ans + a + b + c;
    }
};